package models

import "gorm.io/gorm"

type Book struct {
	gorm.Model
	Title   string `gorm:"type:varchar(20)" json:"title"`
	Name    string `gorm:"type:varchar(10)" json:"name"`
	Contest string `gorm:"type:varchar(50)" json:"contest"`
	Img     string `gorm:"type:varchar(150)" json:"img"`
}

func (c *Book) Add() error {
	return DB.Create(&c).Error
}
func (c *Book) Del() error {
	return DB.Delete(&c).Error
}
func (c *Book) List() (list []Book, err error) {
	err = DB.Find(&list).Error
	return list, err
}
